import http from './servies';

// 获取角色列表
export function getGoodsApi(data: any) {
  return http({
    url: 'goods',
    method: 'get',
    params: data
  })
}

// 获取商品分类数据列表
export function getCategoriesApi() {
  return http({
    url: 'categories',
    method: 'get'
  })
}

// 获取分类参数列表
export function getAttributesApi(id: number, data: any) {
  return http({
    url: 'categories/' + id + '/attributes',
    method: 'get',
    params: data
  })
}

// 添加商品
export function addGoodsApi(data: any) {
  return http({
    url: 'goods',
    method: 'post',
    data
  })
}

// 查询商品
export function getGoodsById(id:any) {
  return http({
    url: 'goods/' + id,
    method: 'get'
  })
}


// 编辑提交商品
export function editGoodsApi(id:any, data:any) {
  return http({
    url: 'goods/' + id,
    method: 'put',
    data
  })
}

// 删除商品
export function delGoodsApi(id:any) {
  return http({
    url: 'goods/' + id,
    method: 'delete'
  })
}

// 获取参数列表
export function getCateListApi(id:any, params: any) {
  return http({
    url: `categories/${id}/attributes`,
    method: 'get',
    params
  })
}

// 添加属性
export function addAttrApi(id:any, data: any) {
  return http({
    url: `categories/${id}/attributes`,
    method: 'post',
    data
  })
}

// 根据ID查询参数
export function getAttrByIdApi(id:any, attrId: any, params: any) {
  return http({
    url: `categories/${id}/attributes/${attrId}`,
    method: 'get',
    params
  })
}

// 编辑提交参数
export function editAttrApi(id:any, attrId: any, data: any) {
  return http({
    url: `categories/${id}/attributes/${attrId}`,
    method: 'put',
    data
  })
}

// 删除参数
export function delAttrApi(id:any, attrId: any) {
  return http({
    url: `categories/${id}/attributes/${attrId}`,
    method: 'delete'
  })
}